<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('入库流水列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>仓库：</label>
                            <select id="warehouseId" name="warehouseId" style="width: 200px">
                                <option value="01">托盘库</option>
                                <option value="02">料箱库</option>
                            </select>
                        </li>
                        <li>
                            <label>任务号：</label>
                            <input type="text" name="taskNo"/>
                        </li>
                        <li>
                            <label>托盘条码：</label>
                            <input type="text" name="trayCode"/>
                        </li>
                        <!--                            <li>-->
                        <!--                                <label>巷道：</label>-->
                        <!--                                <input type="text" name="roadwayId"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <label>货位：</label>-->
                        <!--                                <input type="text" name="cargoSpaceName"/>-->
                        <!--                            </li>-->
                        <!--                        <li>-->
                        <!--                            <label>执行阶段：</label>-->
                        <!--                            <select name="executionPhase" th:with="type=${@dict.getType('execution_phase')}">-->
                        <!--                                &lt;!&ndash;                            <option value="">所有</option>&ndash;&gt;-->
                        <!--                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"-->
                        <!--                                        th:value="${dict.dictValue}"></option>-->
                        <!--                            </select>-->
                        <!--                        </li>-->
<!--                        <li>-->
<!--                            <label>作业类型：</label>-->
<!--                            <select name="inOrOut" th:with="type=${@dict.getType('in_or_out')}">-->
<!--                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"-->
<!--                                        th:value="${dict.dictValue}"></option>-->
<!--                            </select>-->
<!--                        </li>-->
                        <!--                            <li>-->
                        <!--                                <label>开始时间：</label>-->
                        <!--                                <input type="text" name="startTime"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <label>完成时间：</label>-->
                        <!--                                <input type="text" name="finishTime"/>-->
                        <!--                            </li>-->
                        <li>
                            <label>入库主单：</label>
                            <input type="text" name="inOrOutId"/>
                        </li>
                        <!--                            <li>-->
                        <!--                                <label>入库子单据号：</label>-->
                        <!--                                <input type="text" name="inOrOutDId"/>-->
                        <!--                            </li>-->
                        <li>
                            <label>物资编码：</label>
                            <input type="text" name="productId"/>
                        </li>
                        <li>
                            <label>批号：</label>
                            <input type="text" name="lotNo"/>
                        </li>
                        <!--                                <label>入库数量：</label>-->
                        <!--                                <input type="text" name="inQuantity"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <label>生产时间：</label>-->
                        <!--                                <input type="text" name="printDate"/>-->
                        <!--                            </li>-->
                        <li>
                            <label>物资名称：</label>
                            <input type="text" name="productName"/>
                        </li>
                        <li>
                            <label>供应商：</label>
                            <input id="supplierId" name="supplierId" hidden>
                            <input id="supplierName" name="spec" >
                            <a id="selectSupplier" class="btn btn-success" onclick="selectSupplier()" >
                                ...
                            </a>
                        </li>
                        <li>
                            <label>创建时间：</label><input type="text" placeholder="请单击选择开始时间：" autocomplete="off"
                                                       name="startTime" id="startTime"/>---
                            <input type="text" placeholder="请单击选择结束时间：" autocomplete="off" name="finishTime"
                                   id="finishTime"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm"
                               onclick="$.table.search('formId','bootstrap-table')"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm"
                               onclick="$.form.reset('formId','bootstrap-table')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="search:viewInjobHistory:add">-->
            <!--                <i class="fa fa-plus"></i> 添加-->
            <!--            </a>-->
            <!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"-->
            <!--               shiro:hasPermission="search:viewInjobHistory:edit">-->
            <!--                <i class="fa fa-edit"></i> 修改-->
            <!--            </a>-->
            <!--            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"-->
            <!--               shiro:hasPermission="search:viewInjobHistory:remove">-->
            <!--                <i class="fa fa-remove"></i> 删除-->
            <!--            </a>-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()"
                >
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-bordered">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('search:viewInjobHistory:edit')}]];
    var removeFlag = [[${@permission.hasPermi('search:viewInjobHistory:remove')}]];
    var prefix = ctx + "search/viewInjobHistory";
    var executionPhase = [[${@dict.getType('execution_phase')}]];
    var inOrOut = [[${@dict.getType('in_or_out')}]];
    var warehouseId = [[${@dict.getType('is_house')}]];
    var productStatus = [[${@dict.getType('product_status')}]];
    var jobStatus = [[${@dict.getType('job_status')}]];


    layui.use('laydate', function () {
        var laydates = layui.laydate;
        laydates.render({
            elem: '#startTime'
            , type: 'datetime',
            /* ,range: '到' */
            format: 'yyyy-MM-dd HH:mm:ss'
        })
    })

    layui.use('laydate', function () {
        var laydates = layui.laydate;
        laydates.render({
            elem: '#finishTime'
            , type: 'datetime',
            /* ,range: '到' */
            format: 'yyyy-MM-dd HH:mm:ss'
        })
    })

    function selectSupplier(){

        var options = {
            title: '选择物品信息',
            url: "/in/stockin/selectSupplier",
            callBack: getSupplier
        };
        $.modal.openOptions(options);

        function getSupplier(index, layero) {

            var row = layero.find("iframe")[0].contentWindow.submitHandler();
            if (row.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }

            var zTreeDoorData1 = [];
            zTreeDoorData1.splice(0, zTreeDoorData1.length);
            for (var i = 0; i < row.length; i++) {
                $('#supplierId').val(row[i].supplierNo);
                $('#supplierName').val(row[i].supplierName);

            }
            $.modal.close(index);
            $.modal.closeLoading();

        }

    }

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "入库流水",
            clickToSelect: true,//是否启用点击选中行
            uniqueId: "jobDetailId",//表主键(用于修改和删除)
            sortName: "jobDetailId",//必加排序 sortOrder: "asc"默认
            columns: [
                {
                    halign: 'center',
                    align: 'center',
                    checkbox: true
                },
                {
                    title: "序号",
                    halign: 'center',
                    align: 'center',
                    width: 55,
                    formatter: function (value, row, index) {
                        //获取每页显示的数量
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;
                        //获取当前是第几页
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;
                        //返回序号，注意index是从0开始的，所以要加上1
                        return pageSize * (pageNumber - 1) + index + 1;

                    }
                },

                {
                    field: 'jobDetailId',
                    title: '子表ID',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: false
                },
                {
                    field: 'jobId',
                    title: '主键',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: false
                },
                {
                    field: 'status',
                    title: '状态',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(jobStatus, value);
                    }
                },
                {
                    field: 'taskNo',
                    title: '任务号',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'trayCode',
                    title: '托盘条码',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'roadwayId',
                    title: '巷道',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'cargoSpaceName',
                    title: '货位',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'productId',
                    title: '物资编码',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'productName',
                    title: '物资名称',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'lotNo',
                    title: '批号',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'inQuantity',
                    title: '入库数量',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'inOrOut',
                    title: '作业类型',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(inOrOut, value);
                    }
                },
                {
                    field: 'inDate',
                    title: '扫码时间',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'finishTime',
                    title: '完成时间',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'warehouseId',
                    title: '仓库',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(warehouseId, value);
                    }
                },
                {
                    field: 'inOrOutId',
                    title: '入库主单据号',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'inOrOutDId',
                    title: '入库子单据号',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },


            ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>